package jia.ai;

/**
 * Thrown to indicate that a method has been passed a null argument.
 * <p/>
 * The static convenience method <i>check()</i> is a useful shorthand
 * notation for checking whether object constructor method arguments
 * are null:
 * <pre><code>
 * public  Book ( String  title )
 * {
 *   NullArgumentException.check ( this.title = title, "null title" );
 * }
 * </code></pre>
 *
 * @version 1.0
 * @since 01/22/2006
 */
public final class NullArgumentException extends IllegalArgumentException{
    /**
     * Checks whether the argument is null.
     *
     * @throws NullArgumentException If the argument is null.
     */
    public static void check(Object argument){
        if(argument == null) {
            throw new NullArgumentException();
        }
    }
    
    /**
     * Checks whether the argument is null.
     *
     * @param detailMessage The detail message provided if a NullArgumentExcepton is created.
     *
     * @throws NullArgumentException If the argument is null.
     */
    public static void check(Object argument, String detailMessage){
        if(argument == null) {
            throw new NullArgumentException(detailMessage);
        }
    }
    
    /**
     *
     */
    public NullArgumentException(){
    }
    
    /**
     * @param detailMessage
     */
    public NullArgumentException(String detailMessage){
        super(detailMessage);
    }
}